<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->

<!-- Mirrored from minetest.gitlab.io/minetest/metadata/ by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 01 Oct 2020 14:46:27 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  
  
  <link rel="shortcut icon" href="../img/favicon.ico">
  <title>Metadata - Minetest API Documentation</title>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700" />

  <link rel="stylesheet" href="../css/theme.css" />
  <link rel="stylesheet" href="../css/theme_extra.css" />
  <link href="../css/code_styles.css" rel="stylesheet" />
  <link href="../css/extra.css" rel="stylesheet" />
  
  <script>
    // Current page data
    var mkdocs_page_name = "Metadata";
    var mkdocs_page_input_path = "metadata.md";
    var mkdocs_page_url = null;
  </script>
  
  <script src="../js/jquery-2.1.1.min.js" defer></script>
  <script src="../js/modernizr-2.8.3.min.js" defer></script> 
  
</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
    <div class="wy-side-scroll">
      <div class="wy-side-nav-search">
        <a href="../index.html" class="icon icon-home"> Minetest API Documentation</a>
        <div role="search">
  <form id ="rtd-search-form" class="wy-form" action="http://minetest.gitlab.io/minetest/search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" title="Type search term here" />
  </form>
</div>
      </div>

      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../index.html">Home</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../games/index.html">Games</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../mods/index.html">Mods</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../aliases/index.html">Aliases</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../textures/index.html">Textures</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../sounds/index.html">Sounds</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../registered-definitions/index.html">Registered definitions</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../nodes/index.html">Nodes</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../map-terminology-and-coordinates/index.html">Map terminology and coordinates</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../hud/index.html">HUD</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../representations-of-simple-things/index.html">Representations of simple things</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../flag-specifier-format/index.html">Flag Specifier Format</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../items/index.html">Items</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../groups/index.html">Groups</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Tools</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../entity-damage-mechanism/index.html">Entity damage mechanism</a>
                    </li>
                </ul>
                <ul class="current">
                    <li class="toctree-l1 current"><a class="reference internal current" href="index.html">Metadata</a>
    <ul class="current">
    <li class="toctree-l2"><a class="reference internal" href="#node-metadata">Node Metadata</a>
    </li>
    <li class="toctree-l2"><a class="reference internal" href="#item-metadata">Item Metadata</a>
    </li>
    </ul>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../formspec/index.html">Formspec</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../inventory/index.html">Inventory</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../colors/index.html">Colors</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../escape-sequences/index.html">Escape sequences</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../spatial-vectors/index.html">Spatial Vectors</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../helper-functions/index.html">Helper functions</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../translations/index.html">Translations</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../perlin-noise/index.html">Perlin noise</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../ores/index.html">Ores</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../decoration-types/index.html">Decoration types</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../schematics/index.html">Schematics</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../lua-voxel-manipulator/index.html">Lua Voxel Manipulator</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../mapgen-objects/index.html">Mapgen objects</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../registered-entities/index.html">Registered entities</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../l-system-trees/index.html">L-system trees</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../minetest-namespace-reference/index.html">'minetest' namespace reference</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../class-reference/index.html">Class reference</a>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="../definition-tables/index.html">Definition tables</a>
                    </li>
                </ul>
      </div>
    </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../index.html">Minetest API Documentation</a>
      </nav>

      
      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../index.html">Docs</a> &raquo;</li>
    
      
    
    <li>Metadata</li>
    <li class="wy-breadcrumbs-aside">
      
    </li>
  </ul>
  
  <hr/>
</div>
          <div role="main">
            <div class="section">
              
                <h1 id="metadata">Metadata<a class="headerlink" href="#metadata" title="Permanent link">&para;</a></h1>
<h2 id="node-metadata">Node Metadata<a class="headerlink" href="#node-metadata" title="Permanent link">&para;</a></h2>
<p>The instance of a node in the world normally only contains the three values
mentioned in [Nodes]. However, it is possible to insert extra data into a node.
It is called "node metadata"; See <code>NodeMetaRef</code>.</p>
<p>Node metadata contains two things:</p>
<ul>
<li>A key-value store</li>
<li>An inventory</li>
</ul>
<p>Some of the values in the key-value store are handled specially:</p>
<ul>
<li><code>formspec</code>: Defines a right-click inventory menu. See [Formspec].</li>
<li><code>infotext</code>: Text shown on the screen when the node is pointed at</li>
</ul>
<p>Example:</p>
<div class="codehilite"><pre><span></span><code><span class="err">local meta = minetest.get_meta(pos)</span>
<span class="c">meta:set_string(&quot;formspec&quot;,</span>
<span class="c">        &quot;size[8,9]&quot;..</span>
<span class="c">        &quot;list[context;main;0,0;8,4;]&quot;..</span>
<span class="c">        &quot;list[current_player;main;0,5;8,4;]&quot;)</span>
<span class="c">meta:set_string(&quot;infotext&quot;, &quot;Chest&quot;);</span>
<span class="err">local inv = meta:get_inventory()</span>
<span class="c">inv:set_size(&quot;main&quot;, 8*4)</span>
<span class="err">print(dump(meta:to_table()))</span>
<span class="c">meta:from_table({</span>
<span class="c">    inventory = {</span>
<span class="c">        main = {[1] = &quot;default:dirt&quot;, [2] = &quot;&quot;, [3] = &quot;&quot;, [4] = &quot;&quot;,</span>
<span class="c">                [5] = &quot;&quot;, [6] = &quot;&quot;, [7] = &quot;&quot;, [8] = &quot;&quot;, [9] = &quot;&quot;,</span>
<span class="c">                [10] = &quot;&quot;, [11] = &quot;&quot;, [12] = &quot;&quot;, [13] = &quot;&quot;,</span>
<span class="c">                [14] = &quot;default:cobble&quot;, [15] = &quot;&quot;, [16] = &quot;&quot;, [17] = &quot;&quot;,</span>
<span class="c">                [18] = &quot;&quot;, [19] = &quot;&quot;, [20] = &quot;default:cobble&quot;, [21] = &quot;&quot;,</span>
<span class="c">                [22] = &quot;&quot;, [23] = &quot;&quot;, [24] = &quot;&quot;, [25] = &quot;&quot;, [26] = &quot;&quot;,</span>
<span class="c">                [27] = &quot;&quot;, [28] = &quot;&quot;, [29] = &quot;&quot;, [30] = &quot;&quot;, [31] = &quot;&quot;,</span>
<span class="c">                [32] = &quot;&quot;}</span>
<span class="c">    },</span>
<span class="c">    fields = {</span>
<span class="c">        formspec = &quot;size[8,9]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]&quot;,</span>
<span class="c">        infotext = &quot;Chest&quot;</span>
<span class="c">    }</span>
<span class="err">})</span>
</code></pre></div>

<h2 id="item-metadata">Item Metadata<a class="headerlink" href="#item-metadata" title="Permanent link">&para;</a></h2>
<p>Item stacks can store metadata too. See [<code>ItemStackMetaRef</code>].</p>
<p>Item metadata only contains a key-value store.</p>
<p>Some of the values in the key-value store are handled specially:</p>
<ul>
<li><code>description</code>: Set the item stack's description. Defaults to
  <code>idef.description</code>.</li>
<li><code>color</code>: A <code>ColorString</code>, which sets the stack's color.</li>
<li><code>palette_index</code>: If the item has a palette, this is used to get the
  current color from the palette.</li>
</ul>
<p>Example:</p>
<div class="codehilite"><pre><span></span><code><span class="err">local meta = stack:get_meta()</span>
<span class="c">meta:set_string(&quot;key&quot;, &quot;value&quot;)</span>
<span class="err">print(dump(meta:to_table()))</span>
</code></pre></div>
              
            </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="../formspec/index.html" class="btn btn-neutral float-right" title="Formspec">Next <span class="icon icon-circle-arrow-right"></span></a>
      
      
        <a href="../entity-damage-mechanism/index.html" class="btn btn-neutral" title="Entity damage mechanism"><span class="icon icon-circle-arrow-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <!-- Copyright etc -->
    
  </div>

  Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org/">Read the Docs</a>.
</footer>
      
        </div>
      </div>

    </section>

  </div>

  <div class="rst-versions" role="note" aria-label="versions">
    <span class="rst-current-version" data-toggle="rst-current-version">
      
      
        <span><a href="../entity-damage-mechanism/index.html" style="color: #fcfcfc;">&laquo; Previous</a></span>
      
      
        <span style="margin-left: 15px"><a href="../formspec/index.html" style="color: #fcfcfc">Next &raquo;</a></span>
      
    </span>
</div>
    <script>var base_url = '../index.html';</script>
    <script src="../js/theme.js" defer></script>
      <script src="../search/main.js" defer></script>
    <script defer>
        window.onload = function () {
            SphinxRtdTheme.Navigation.enable(true);
        };
    </script>

</body>

<!-- Mirrored from minetest.gitlab.io/minetest/metadata/ by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 01 Oct 2020 14:46:27 GMT -->
</html>
